/*
 * Copyright 2016-2019 yoara
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package yhao.infra.feature.solr.local.core.facet;

import org.apache.solr.client.solrj.response.FacetField;

import java.util.List;

/**
 * Facet查询数据包装类
 *
 * @author yoara
 */
public class SolrFacetBean{
    private int queryCount; //query 查询的结果数
    List<FacetField.Count> fieldCount;
    private String facetField;
    private String facetFieldValue;


    public String getFacetField() {
        return facetField;
    }

    public String getFacetFieldValue() {
        return facetFieldValue;
    }

    public SolrFacetBean(String facetField,String facetFieldValue) {
        this.facetField = facetField;
        this.facetFieldValue = facetFieldValue;
    }

    /**
     * 拼装facet查询语句
     * @return
     */
    public String createFacetQuery() {
        if(facetFieldValue==null){
            return null;
        }
        StringBuilder facetQuery = new StringBuilder();
        facetQuery.append(facetField);
        facetQuery.append(":");
        facetQuery.append(facetFieldValue);
        return facetQuery.toString();
    }

    public List<FacetField.Count> getFieldCount() {
        return fieldCount;
    }

    protected void setFieldCount(List<FacetField.Count> fieldCount) {
        this.fieldCount = fieldCount;
    }

    public int getQueryCount() {
        return queryCount;
    }

    public void setQueryCount(int queryCount) {
        this.queryCount = queryCount;
    }
}
